/**
 * Created by Jie on 2017/2/8.
 */
var express = require('express');
var router = express.Router();

var garrisonConfig = require('../controller/business/devicesGarrisonConfigController');
var devices = require('../controller/business/devicesController');

//设备路由配置
router.get('/',devices.index);
router.get('/get/:id',devices.one);
router.get('/del/:id',devices.del);
router.get('/all',devices.all);
router.get('/form/:id',devices.form);

router.post('/list',devices.list);
router.post('/opt/:id',function (req,res) {
    if(req.params.id==0){
        devices.insert(req,res);
    }else {
        devices.edit(req,res);
    }
});

//驻防路由配置
router.get('/garrison',garrisonConfig.index);
router.get('/garrison/get/:id',garrisonConfig.one);
router.get('/garrison/del/:id',garrisonConfig.del);
router.get('/garrison/all',garrisonConfig.all);
router.get('/garrison/form/:id',garrisonConfig.form);

router.post('/garrison/list',garrisonConfig.list);
router.post('/garrison/opt/:id',function (req,res) {
    if(req.params.id==0){
        garrisonConfig.insert(req,res);
    }else {
        garrisonConfig.edit(req,res);
    }
});

module.exports = router;